{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.colors as colors\n",
    "import matplotlib.cbook as cbook\n",
    "import sys\n",
    "dirwork ='TCHEM_INSTALL_PATHexample/runs/scripts/'\n",
    "sys.path.append(dirwork)\n",
    "import pmixSample"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1200.0 1200\n",
      "0.8333333333333334 0.8333333333333334\n"
     ]
    }
   ],
   "source": [
    "# Pressure, Temperature, phi(stoichiometric ratio)\n",
    "one_atm = 101325\n",
    "TempMax = 1200.\n",
    "TempMin = 1200 #1300; #K\n",
    "\n",
    "PressureMax = 1*one_atm; # atm\n",
    "PressureMin = 1*one_atm; # atm\n",
    "\n",
    "phiMax = 1; # \n",
    "phiMin = 1; # \n",
    "print(TempMax,TempMin)\n",
    "print(1000/TempMax,1000/TempMin)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "p 1\n"
     ]
    }
   ],
   "source": [
    "Npp = 1\n",
    "Npt = 1\n",
    "Npphi = 1\n",
    "N = Npp*Npt*Npphi\n",
    "pressure    = [PressureMin]#[PressureMin, PressureMax] # , np.linspace(PressureMin, PressureMax, Npp) #\n",
    "temperature = np.linspace(TempMin, TempMax, Npt)\n",
    "eqratio     = np.linspace(phiMin, phiMax, Npphi)\n",
    "p, temp, phi = np.meshgrid(pressure, temperature,eqratio)\n",
    "print('p',np.size(p))\n",
    "p    = p.reshape(np.size(p)) #flatten()\n",
    "temp = temp.reshape(np.size(temp))#flatten()\n",
    "phi  = phi.reshape(np.size(phi))#flatten()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1.]\n"
     ]
    }
   ],
   "source": [
    "print(phi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "Nvar = 6\n",
    "sample = np.zeros([N,Nvar])\n",
    "fuel =\"C4H10\"\n",
    "nC=4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(N):\n",
    "    sample[i,0] = temp[i]\n",
    "    sample[i,1] = p[i]\n",
    "    Yp_fuel, Yr_o2, Yr_n2, Yr_ar = pmixSample.getMassFraction(nC,phi[i])\n",
    "    sample[i,2] = Yp_fuel\n",
    "    sample[i,3] = Yr_o2\n",
    "    sample[i,4] = Yr_n2 \n",
    "    sample[i,5] = Yr_ar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "savedir = ''\n",
    "header_fuel = \"T P \"+fuel+\" O2 N2 AR\"\n",
    "np.savetxt(savedir+'sample.dat',sample,header=header_fuel,comments='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
